<template>
  <div>

    <!-- 阿里云视频播放器样式 -->
    <link rel="stylesheet" href="https://g.alicdn.com/de/prismplayer/2.8.1/skins/default/aliplayer-min.css" >
    <!-- 阿里云视频播放器脚本 -->
    <script charset="utf-8" type="text/javascript" src="https://g.alicdn.com/de/prismplayer/2.8.1/aliplayer-min.js" />

    <!-- 定义播放器dom -->
    <div id="J_prismPlayer" class="prism-player" />
  </div>
</template>

<script>
  import videoApi from '@/api/video'

  export default {
    layout: 'video',
    asyncData({params, error}){
      return videoApi.getPlayAuth(params.id).then(resp => {
        return {videoId: params.id, playAuth: resp.data.data.auth}
      })
    },
    mounted() {
      new Aliplayer({
        id: 'J_prismPlayer',
        vid: this.videoId,
        playauth: this.playAuth,
        encryptType: '1',
        width: '100%',
        height: '500px',
        autoplay: false
      },function (player) {

      })
    },
  }
</script>

<style scoped>

</style>
